﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Top.Api;
using Top.Api.Request;
using Top.Api.Response;

namespace MicroAmoy.Util.AliTop
{
    public class AliItem
    {
        /// <summary>
        /// 生成淘宝口令
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public static string GetSku(ItemSkuGetRequest req)
        {
            try
            {
                ItemSkuGetResponse rsp = TopClient.Execute(req);
                if (rsp.IsError)//失败
                    return rsp.ErrMsg;
                return FastJSON.JSON.ToJSON(rsp);//BizResult不为空
            }
            catch (System.Exception ex)
            {

            }
            return "failed";
        }
        private static ITopClient TopClient
        {
            get { return new DefaultTopClient(Config.APPURL, Config.APPKEY, Config.APPSECRET); }
        }
        class Config : ConfigBase
        {
            //=======【基本信息设置】=====================================
            /* 淘口令中心账号信息配置
            * APPID：应用账户（必须配置）
            * APPSECRET：应用secert
            * APPURL：应用请求地址
            */
            public const string APPKEY = "23758258";
            public const string APPSECRET = "1cdeda4ba1edacaa2078a70c6b093eea";
        }
    }
}
